﻿using System;

namespace TryAndCatchTest
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");
            while (true)
            {


                try
                {
                    Console.Write("请输入:");
                    string num = Console.ReadLine();
                    int index = Convert.ToInt32(num);
                    if (index >= 1)
                    {
                        Console.WriteLine("正确");
                    }
                    else
                    {
                        int y = Zero(0);
                    }

                }

                catch (DivideByZeroException)
                {
                    throw new Exception("错误");
                }

            }

        }

        public static int Zero(int x)
        {
            return 10 / x;
        }

    }
}
